package com.smart.seckilldemo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.smart.seckilldemo.mapper.SeckillOrderMapper;
import com.smart.seckilldemo.pojo.Order;
import com.smart.seckilldemo.pojo.SeckillOrder;
import com.smart.seckilldemo.service.SeckillOrderService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class SeckillOrderServiceImpl implements SeckillOrderService {

    @Resource
    SeckillOrderMapper seckillOrderMapper;

    /**、
     * 查询订单
     * @param userId
     * @param goodsId
     * @return
     */
    @Override
    public SeckillOrder getOne(Long userId,Long goodsId) {

        QueryWrapper<SeckillOrder> qw = new QueryWrapper<>();
        qw.eq(SeckillOrder.COL_USER_ID,userId).eq(SeckillOrder.COL_GOODS_ID,goodsId);

        SeckillOrder seckillOrder = seckillOrderMapper.selectOne(qw);
        return seckillOrder;
    }

    /**
     * 添加订单
     * @param seckillOrder
     * @return
     */
    @Override
    public Integer insertOrder(SeckillOrder seckillOrder) {

        int insert = seckillOrderMapper.insert(seckillOrder);

        return insert;
    }



}
